package test2;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.util.ASMifier;
import org.objectweb.asm.util.TraceClassVisitor;

import java.io.*;

public class AsmDump {
    public static Class TARGET_CLASS = YewuBean.class;
    public static void main(String[] args) throws Exception{

        String name= TARGET_CLASS.getName().replaceAll("\\.","/");

        String fileName = "aop-asm-impl/src/test/java/asm/"+name+"Dump.java";
        File file = new File(fileName);
        file.getParentFile().mkdirs();
        System.out.println(file);
        OutputStream os = new FileOutputStream(fileName);

        InputStream is = AsmDump.class.getResourceAsStream("/"+name+".class");
        ClassReader classReader = new ClassReader(is);
        ClassVisitor classVisitor = new TraceClassVisitor(null, new ASMifier()
                , new PrintWriter(os)
//                ,new PrintWriter(System.out)
        );
        classReader.accept(classVisitor
                ,0
//                , ClassReader.SKIP_FRAMES
        );
    }
}
